import 'package:redux/redux.dart';

import 'book.dart';

final BookReducer = combineReducers<Book>([
  TypedReducer<Book, AddBookAction>(_add),
  TypedReducer<Book, UpdateBookAction>(_update),
]);

Book _add(Book book, AddBookAction addBookAction) {
  addBookAction.book.name = "西游记";
  book = addBookAction.book;
  return book;
}

Book _update(Book book, UpdateBookAction updateBookAction) {
  updateBookAction.book.name = "更新书名";
  book = updateBookAction.book;
  return book;
}

class AddBookAction {
  Book book;

  AddBookAction(this.book);
}

class UpdateBookAction {
  Book book;

  UpdateBookAction(this.book);
}
